#! /bin/sh
# PCP QA Test No. 000
# check how many processes we have running and their arguments
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard filters
. ./common.product
. ./common.filter

trap "rm -f $tmp.*; exit" 0 1 2 3 15

# check PMCS processes
rm -f $tmp.err
# pmdaoracle is optional, so skip it and other optional ones
$PCP_PS_PROG $PCP_PS_ALL_FLAGS \
| _filter_optional_pmdas \
| sed \
    -e '/dbpmda/d' \
    -e '/<defunct>/d' \
| $PCP_AWK_PROG '
$7 == "TIME" || $10 == "TIME"		{ next }
		    { want = 0
		      psargs = 0
		      for (i = 12; i >= 7; i--) {
			# most ps variants have TIME as N:NN
			if ($i ~ /[0-9]:[0-9][0-9]$/) {
			    psargs=i+1
			    break
			}
			# darwin ps has TIME as N:NN.NN
			if ($i ~ /[0-9]:[0-9][0-9]\.[0-9][0-9]$/) {
			    psargs=i+1
			    break
			}
		      }
		      if (psargs == 0) {
			print "Error: cannot find psargs in this ps line" >"'$tmp.err'"
			print $0 >"'$tmp.err'"
			next
		      }
		    }
$psargs ~ /pmcd/	{ want = 1 }
$psargs ~ /pmda/	{ want = 1 }
want == 1		{ print $psargs }' \
| sed \
    -e 's;.*/\([^/]*\);\1;' \
| LC_COLLATE=POSIX sort

if [ -s $tmp.err ]
then
    echo
    echo "Warnings ..."
    cat $tmp.err
fi
